import * as actionTypes from "./constants";

import {
  getDjCatelist,
  getProgramRecommend,
  getProgramToplist,
  getDjRadioHot,
  getDjRadioRecommend,
} from "@/services/djradio";

const djCatelistAction = (res) => ({
  type: actionTypes.DJCATELIST,
  djCatelists: res,
});
const getProgramRecommendAction = (res) => ({
  type: actionTypes.GETPROGRAMRECOMMEND,
  djProgramRecommend: res,
});
const getProgramToplistAction = (res) => ({
  type: actionTypes.GETPROGRAMTOPLIST,
  djProgramToplist: res,
});

const getDjRadioRecommendTypeAction = (res) => ({
  type: actionTypes.GETDJRADIORECOMMENDTYPE,
  djRadioRecommend: res,
});

const getDjRadioHottAction = (res) => ({
  type: actionTypes.GETDJRADIOHOT,
  DjRadioHotLists: res,
});

export const getDjCatelists = () => {
  return (dispatch) => {
    getDjCatelist().then((res) => {
      dispatch(djCatelistAction(res));
    });
  };
};
export const getProgramRecommends = () => {
  return (dispatch) => {
    getProgramRecommend().then((res) => {
      dispatch(getProgramRecommendAction(res));
    });
  };
};
export const getProgramToplists = (limit, offset) => {
  return (dispatch) => {
    getProgramToplist(limit, offset).then((res) => {
      dispatch(getProgramToplistAction(res));
    });
  };
};
export const getDjRadioRecommendType = (type) => {
  return (dispatch) => {
    getDjRadioRecommend(type).then((res) => {
      dispatch(getDjRadioRecommendTypeAction(res));
    });
  };
};
export const getDjRadioHotLists = (cateId, limit, offset) => {
  return (dispatch) => {
    getDjRadioHot(cateId, limit, offset).then((res) => {
      dispatch(getDjRadioHottAction(res));
    });
  };
};
